<template>
    <view class="content" v-if="isShow">
        <view class="nav">
            <view class="nav-i" :class="{active : type == 1}" @click="chooseNav(1)">未结算({{count.count1}})</view>
            <view class="nav-i" :class="{active : type == 2}" @click="chooseNav(2)">已结算({{count.count2}})</view>
			<view class="nav-i" :class="{active : type == 3}" @click="chooseNav(3)">已拒绝({{count.count3}})</view>
        </view>
        
        <view class="box" v-for="(item, index) in list" :key="index" @click="toDetails(item)">
            <view class="item">
                <view class="left">提交日期</view>
                <view class="right">{{item.create_time}}</view>
            </view>
            <view class="item">
                <view class="left">结算金额</view>
                <view class="right">￥{{item.cost}}</view>
            </view>
            <view class="btns">
                <view class="btn1">查看详情</view>
            </view>
        </view>
		
		<view style="height: 94rpx;padding-top: 30rpx;">
		    <u-loadmore :status="status" v-if="status != 'loadmore'" />
		</view>
        
        <view class="footer" @click="$gTo(`/pages/settlement-xh/create`)">添加</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                type: 1,
				isShow: false,
				status: 'loadmore', //是否显示没有更多了
				page: 1,
				list: [],
				count: {},
            };
        },
        onShow() {
        	this.list = []
        	this.page = 1
        	this.status = 'loadmore'
        	this.getList()
        },
        onReachBottom() {
        	if(this.page == 1){return}
        	this.getList()
        },
        methods: {
            toDetails(item) {
                this.$gTo(`/pages/settlement-xh/details?id=${item.id}&type=${this.type}`)
            },
            
            chooseNav(num) {
				if (this.type == num) return
                this.type = num
				this.list = []
				this.page = 1
				this.status = 'loadmore'
				this.getList()
            },
			
			getList() {
				if (this.status == 'nomore') return;
				this.status = 'loading';
				this.$ajax('settlement_doc', {
					user_token: this.$getSync('userToken'),
					page: this.page,
					limit: 10,
			        status: this.type,//1未结算 2已结算 3已拒绝
				}).then(ret => {
					if (ret.success == 1000) {
						this.count = ret.detail
						
						if (ret.detail && ret.detail.settlement_doc && ret.detail.settlement_doc.length > 0) {
							this.list = this.list.concat(ret.detail.settlement_doc);
							this.page++;
							this.status = 'loadmore'
						} else {
							this.status = 'nomore'
						}
						this.isShow = true
					} else {
						this.$toast(ret.msg);
					}
				});
			},
        }
    };
</script>

<style lang="scss">
    
    page{
        background-color: #eef1f6;
    }
    .content{
        padding-bottom: 50rpx;
    }
    .nav{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30rpx 0;
        border-bottom: 2rpx solid #ebebeb;
        background-color: #fff;
    }
    .nav-i{
        width: calc(100vw / 3);
        font-size: 28rpx;
        text-align: center;
        position: relative;
    }
    .active{
        color: #004580;
        font-weight: bold;
        position: relative;
    }
    .active::after{
        display: block;
        content: '';
        width: 32rpx;
        height: 8rpx;
        background-color: #004580;
        position: absolute;
        bottom: -30rpx;
        left: 50%;
        transform: translateX(-50%);
    }
    .nav2-r{
        display: flex;
        justify-content: flex-end;
        align-items: center;
        font-size: 24rpx;
        color: #737373;
        padding-bottom: 30rpx;
    }
    .time{
        min-width: 210rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: #000;
        margin-left: 12rpx;
        padding: 15rpx;
        background-color: #fff;
        border-radius: 10rpx;
    }
    .time-icon{
        width: 25rpx;
        height: 25rpx;
        margin-left: 20rpx;
    }
    
    
    .box{
        padding: 35rpx 30rpx;
        margin: 15rpx 20rpx;
        background-color: #fff;
        border-radius: 20rpx;
    }
    .top{
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 8rpx;
        font-size: 28rpx;
    }
    .left{
        width: 160rpx;
        color: #656565;
    }
    .right{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
    }
    .del-02{
        width: 32rpx;
        height: 32rpx;
        margin-left: 15rpx;
    }
    .btns{
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }
    .btn1{
        padding: 15rpx 25rpx;
        background-color: #99aeca;
        border-radius: 50rpx;
        color: #fff;
    }
    .footer{
        width: 100%;
        height: 90rpx;
        background-color: #00457f;
        font-size: 34rpx;
        color: #fff;
        text-align: center;
        line-height: 90rpx;
        position: fixed;
        left: 0;
        bottom: 0;
        z-index: 9;
    }

</style>
